package authorize

import (
	"fmt"
	"ginfwk/infrastructure/helper/ghttp"
	"github.com/gin-gonic/gin"
)

type Authorize struct {
}

// UserLogin 用户登录
func (u *Authorize) UserLogin(g *gin.Context) interface{} {
	param := struct {
		Username string `json:"username"`
		Password string `json:"password"`
	}{}
	if err := g.ShouldBindJSON(&param); err != nil {
		return ghttp.Fail(-1, fmt.Sprintf("登录失败: %s", err.Error()))
	}

	// 执行登录逻辑

	// 获取用户信息并返回
	userInfo := gin.H{
		"permissions": []string{"*.*.*"},
		"role":        "admin",
		"roleId":      "1",
		"username":    "admin",
	}
	return ghttp.Success(userInfo)
}
